/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javamail.config;

/**
 *
 * @author sriram
 */
public class cliParms {
    String config_file_name = null;
    String sip_uri = null;
    String http_bind_address;
    boolean error = false;

    public cliParms(String[] parms) {
        for(int i=0;i<parms.length/2;i++) {
            if(parms[2*i].equals("-c")) {
                config_file_name = parms[2*i+1];
            } else if(parms[2*i].equals("-user")) {
                sip_uri = parms[2*i+1];
                if(!isSipValid(sip_uri))
                    error = true;
            } else if(parms[2*i].equals("-http")) {
                http_bind_address = parms[2*i+1];
            } else
                error = true;
        }
    }

    public boolean isError() {
        return error;
    }
    public boolean isSipValid(String str) {
        if(str.length()>=3)
            if((str.indexOf('@')>0) && (str.indexOf(":")>2)) {
                return true;
            }
        return false;
    }
}
